from utils import MainHandler, LLMType, EmbeddingType

# 初始化主处理类
main_handler = MainHandler(
    llm_type=LLMType.Online_OpenAILike,
    embedding_type=EmbeddingType.Local_HuggingFace,
    llm_model_name="deepseek-ai/DeepSeek-V3",
    api_base="https://api.siliconflow.cn/v1",
    is_function_calling_model=True,
)

# 读取知识库并创建向量数据库，这个创建过程只需要运行一次
# main_handler.create_vector_database(knowledge_path="./knowledge")

# ======================
# 创建查询引擎
query_engine = main_handler.get_router_query_engine(
    vector_database_path="./storage",
)

# 尝试查询
query = "哪些商品支持退货？"
response = query_engine.query(query)

# 使用流式输出打印结果
for chunk in response.response_gen:
    print(chunk, end="", flush=True)
